package com.naiterui.ehp.bs.agent.util;

import com.naiterui.ehp.bp.utils.lang.ConfigUtil;
import org.apache.commons.lang3.StringUtils;

/**
 * @author yiren
 * @since 2022/2/25
 */
public class ImgPathUtil {
	/**
	 * 将文件path转化成url
	 * @param path
	 * @return
	 */
	public static String pathToUrl(String path){
		String url = "";
		if (StringUtils.isNotEmpty(path)) {
			if (path.startsWith("http")){
				url = path;
			}else{
				url = ConfigUtil.getString("ehp.domain.img") + path;
			}
		}
		return url;
	}

	/**
	 * 将文件url转化成path
	 * @param url
	 * @return
	 */
	public static String urlToPath(String url){
		String path = "";
		if (StringUtils.isNotEmpty(url)) {
			path = url.replace(ConfigUtil.getString("ehp.domain.img"),"");
		}
		return path;
	}
}
